package com.yj.jason.jsondemo.fragment;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.widget.AbsListView;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;

public class MySmartRefrehsLayout extends SmartRefreshLayout {

    private GestureDetector gestureDetector;
    private boolean intercept;

    private View mDragListView;


    public MySmartRefrehsLayout(Context context) {
        this(context,null);
    }

    public MySmartRefrehsLayout(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public MySmartRefrehsLayout(final Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);


    }


    float lastx,lasty=0;
    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return false;
    }




    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        mDragListView=getChildAt(0);

    }

    public boolean canChildScrollUp() {
        if (mDragListView != null) {
            if (android.os.Build.VERSION.SDK_INT < 14) {
                if (mDragListView instanceof AbsListView) {
                    final AbsListView absListView = (AbsListView) mDragListView;
                    return absListView.getChildCount() > 0
                            && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                            .getTop() < absListView.getPaddingTop());
                } else {
                    return ViewCompat.canScrollVertically(mDragListView, -1) || mDragListView.getScrollY() > 0;
                }
            } else {
                return ViewCompat.canScrollVertically(mDragListView, -1);
            }
        }
        return false;
    }
}
